#include<bits/stdc++.h>
using namespace std;
int main(){
    //freopen("in.txt","r",stdin);
    int M,N,K;
    scanf("%d %d %d",&M,&N,&K);
    stack<int>a;
    queue<int>b;
    int tmp;
    for(int i=0;i<K;i++){
        for(int j=0;j<N;j++){
            scanf("%d",&tmp);
            b.push(tmp);
        }
        for(int j=1;j<=N;j++){
            if(a.size()>=M)break;
            a.push(j);
            while(!a.empty() && a.top()==b.front()){
                a.pop();b.pop();
            }
        }
        if(a.empty()){printf("YES\n");}
        else{printf("NO\n");}
        while(!a.empty()){a.pop();}
        while(!b.empty()){b.pop();}
    }
}
